/*
 *
 gcc s.c -L. -lglut32 -lopenGL32 -lglu32 -lGLESv2 -lmingw32 -lSDL2_test -lSDL2main -lSDL2 && a 
 gcc s.c SDL_test_common.c -lm -lSDL2 && ./a.out && ./a.out
 gcc s.c -llibGLESv2 -lSDL2_test -lm -lmingw32 -lSDL2main -lSDL2   && a
 adb push 2.c /sdcard/ &&
 Copyright (r) 1997-2014 Sam Lantinga <slouken@libsdl.org>

 This software is provided 'as-is', without any express or implied
 warranty.  In no event will the authors be held liable for any damages
 arising from the use of this software.

 Permission is granted to anyone to use this software for any purpose,
 including commercial applications, and to alter it and redistribute it
 freely.
 */

#pragma comment(lib,"glut32.lib")

#include <stdlib.h>
#include <Windows.h>
#include <GL/glew.h>
#include <GL/glut.h>

void init(void)
{
	glClearColor(0.0,0.0,0.0,0.0);
	glShadeModel(GL_FLAT);
}

void display(void)
{
	glColor3f(1.0,1.0,1.0);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	//绘制正方形
	glBegin(GL_LINE_LOOP);
	glVertex3f(-0.5,0.5,0.0);
	glVertex3f(0.5,0.5,0.0);
	glVertex3f(0.5,-0.5,0.0);
	glVertex3f(-0.5,-0.5,0.0);
	glEnd();

	glFlush();

}

void reshape(int w,int h)
{
	glViewport(0,0,(GLsizei)w,(GLsizei)h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble)h);
}

int main(int argc,char** argv)
{
	glutInit(&argc,argv);
	glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
	glutInitWindowSize(500,500);
	glutInitWindowPosition(100,100);
	glutCreateWindow(argv[0]);
	init();
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMainLoop();
	return 0;
}

